﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Dapper;

namespace CodeRepositoryConsole.ORM.Dapper
{
    public class DapperTestDriver
    {
        public void Test()
        {
            var customer = new Customer()
            {
                CustomerID=2,
                CustomerFirstName = "eee",
                CustomerLastName = "FFF",
                IsActive = false
            };

            CustomerRespository customerRespository = new CustomerRespository();
            customerRespository.UpdateCustomer(customer);

            customerRespository.InsertCustomerRetId(customer);

            customerRespository.DeleteCustomer(4);

            var ourCustomers = customerRespository.GetCustomers(5, "");

            foreach (var item in ourCustomers)
            {
                Console.WriteLine(new String('*', 20));
                Console.WriteLine("\nCustomer ID: " + item.CustomerID);
                Console.WriteLine("First Name: " + item.CustomerFirstName);
                Console.WriteLine("Second Name: " + item.CustomerLastName);
                Console.WriteLine("Is Active? " + item.IsActive + "\n");
                Console.WriteLine(new String('*', 20));
            }

            customer = customerRespository.GetSingleCustomer(2);
            Console.WriteLine(new String('*', 20));
            Console.WriteLine("Get by single");
            Console.WriteLine("\nCustomer ID: " + customer.CustomerID);
            Console.WriteLine("First Name: " + customer.CustomerFirstName);
            Console.WriteLine("Second Name: " + customer.CustomerLastName);
            Console.WriteLine("Is Active? " + customer.IsActive + "\n");
            Console.WriteLine(new String('*', 20));
        }

    }
}
